//
//  MoreAlbumCollectionViewCell.m
//  DolphinMusic
//
//  Created by dllo on 15/3/26.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "MoreAlbumCollectionViewCell.h"

@implementation MoreAlbumCollectionViewCell

- (void)dealloc
{
    [_album release];
    [_authorLabel release];
    [_titleLabel release];
    [_coverImageView release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.coverImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.coverImageView];
        [_coverImageView release];
        
        self.titleLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.titleLabel];
        [_titleLabel release];
        
        self.authorLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.authorLabel];
        [_authorLabel release];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
}

- (void)setAlbum:(Album *)album
{
    if (_album != album) {
        [_album release];
        _album = [album retain];
    }
    
    self.coverImageView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.width);
    [self.coverImageView setImageWithURL:[NSURL URLWithString:[self.album.pic_big stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
    self.titleLabel.frame = CGRectMake(0, self.contentView.frame.size.width, self.contentView.frame.size.width, 20);
    self.titleLabel.text = self.album.title;
    
    self.authorLabel.frame = CGRectMake(0, self.contentView.frame.size.width + 20, self.contentView.frame.size.width, 20);
    self.authorLabel.text = self.album.author;
    self.authorLabel.alpha = 0.7;
    self.authorLabel.font = [UIFont systemFontOfSize:15];
}

@end
